/*************************************************************************
 *  Copyright (C), 2017-2018, Mogoson tech. Co., Ltd.
 *  FileName: CubeAreaEditor.cs
 *  Author: Mogoson   Version: 1.0   Date: 7/11/2017
 *  Version Description:
 *    Internal develop version,mainly to achieve its function.
 *  File Description:
 *    Ignore.
 *  Class List:
 *    <ID>           <name>             <description>
 *     1.        CubeAreaEditor            Ignore.
 *  Function List:
 *    <class ID>     <name>             <description>
 *     1.
 *  History:
 *    <ID>    <author>      <time>      <version>      <description>
 *     1.     Mogoson     7/11/2017       1.0        Build this file.
 *************************************************************************/

namespace Developer.AreaRoam
{
    using UnityEditor;
    using UnityEngine;

    [CustomEditor(typeof(CubeArea), true)]
    [CanEditMultipleObjects]
    public class CubeAreaEditor : AREditor
    {
        #region Property and Field
        protected CubeArea script { get { return target as CubeArea; } }
        protected int[] segmentIndices = { 0, 1, 1, 2, 2, 3, 3, 0, 0, 4, 1, 5, 2, 6, 3, 7, 4, 5, 5, 6, 6, 7, 7, 4 };
        #endregion

        #region Private Method
        protected virtual void OnSceneGUI()
        {
            var points = new Vector3[8];
            points[0] = script.transform.TransformPoint(new Vector3(-script.radius.x, -script.radius.y, script.radius.z));
            points[1] = script.transform.TransformPoint(new Vector3(-script.radius.x, script.radius.y, script.radius.z));
            points[2] = script.transform.TransformPoint(new Vector3(script.radius.x, script.radius.y, script.radius.z));
            points[3] = script.transform.TransformPoint(new Vector3(script.radius.x, -script.radius.y, script.radius.z));
            points[4] = script.transform.TransformPoint(new Vector3(-script.radius.x, -script.radius.y, -script.radius.z));
            points[5] = script.transform.TransformPoint(new Vector3(-script.radius.x, script.radius.y, -script.radius.z));
            points[6] = script.transform.TransformPoint(new Vector3(script.radius.x, script.radius.y, -script.radius.z));
            points[7] = script.transform.TransformPoint(new Vector3(script.radius.x, -script.radius.y, -script.radius.z));

            Handles.color = blue;
            Handles.DrawLines(points, segmentIndices);
        }
        #endregion
    }//class_end
}//namespace_end